package com.littlebee.storychild.ui;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.littlebee.storychild.R;
import com.littlebee.storychild.common.utils.Constant;
import com.littlebee.storychild.common.utils.ToastUtil;
import com.zss.library.activity.BaseActivity;
import com.zss.library.toolbar.CommonToolbar;

public class LauchActivity extends BaseActivity {
    EditText numberEt;
    TextView goTv;
    SharedPreferences sharedPreferences;

    @Override
    public void initView() {
        super.initView();
        sharedPreferences = getSharedPreferences(Constant.appName, Context.MODE_PRIVATE); //私有数据

        numberEt=(EditText) findViewById(R.id.show_et);
        goTv=(TextView)findViewById(R.id.go_tv);
        goTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(TextUtils.isEmpty(numberEt.getText().toString())){
                    ToastUtil.displayShortToast("请输入串号后两位");
                    return;
                }

                /**用来清除数据*/
                sharedPreferences.edit().putBoolean("isFirst_Story", false).commit();
                sharedPreferences.edit().putString("isFirst_Story_Time", "").commit();

                sharedPreferences.edit().putBoolean("isFirst_Eng", false).commit();
                sharedPreferences.edit().putString("isFirst_Eng_Time", "").commit();

                sharedPreferences.edit().putBoolean("isFirst_Rec", false).commit();

                Intent intent=new Intent(LauchActivity.this,MainActivity.class);
                //intent.putExtra("no","HB600000"+numberEt.getText().toString());
                sharedPreferences.edit().putString("DID","HB600000"+numberEt.getText().toString()).commit();
                startActivity(intent);
                finish();

            }
        });
    }


    @Override
    public int getLayoutResId() {
        return R.layout.activity_lauch;
    }
    @Override
    public void setTopBar() {
        super.setTopBar();
        setStatusBarColor(R.color.module_video_bg);
        CommonToolbar toolbar = getToolbar();
        toolbar.setBgRes(R.color.trans);
        toolbar.setTitle(getString(R.string.app_name));
        toolbar.setLeftShow(false);



    }
}
